﻿#ifndef __SS_LE_NETWORK_H__
#define __SS_LE_NETWORK_H__
#include "thread/ssThreadBase.h"
#include "ssLeServer.h"

namespace StarSeeker
{

class ssLeNetwork;
//网络线程
class ssLeServerThread : protected ssThreadBase, protected ssLeServer
{
public:
	ssLeServerThread();
	~ssLeServerThread();
	//启动网络服务
	bool StartNetWork(const char* ip, const u16 port, bool isClient, ssLeNetwork* pNetwork);
	//停止网络服务
	void StopNetWork();
	//
	bool IsClient() { return m_isClient; }
	//重新连接
	bool Reconnect();
	//设置读写缓冲区
	void SetRWSize(u32 len);
	//是否处理粘包，0不处理，1按照ssNetMsgHead处理
	void SetParsePackageMode(u8 mode);
private:
	virtual void ThreadMemberFunc();
	virtual void OnNewConnection(ssLeSession *session);
	virtual void OnReceive(ssLeSession *session, char *data, u32 len);
	virtual void OnError(ssLeSession *session, short error);
private:
	ssLeNetwork*	m_pNetwork;
};

}
#endif
